package Homework;

import java.io.BufferedReader; 
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;

public class Homework01 {
	public static void main(String[] args) throws IOException {
		BufferedReader	br = new BufferedReader(new FileReader("test.txt"));
		ArrayList<String> sort = new ArrayList<>();
		String line=null;
		while((line = br.readLine())!=null){
			sort.add(line);
		}
		Collections.sort(sort);
		System.out.println(sort);
		
		br.close();
		BufferedWriter	bw = new BufferedWriter(new FileWriter("test"));
		for(String s : sort){
			bw.write(s);
			bw.newLine();
		}
		bw.close();
		
	}
	
}
